package tech.aistar.mapper;

import org.apache.ibatis.annotations.*;
import tech.aistar.pojo.Comment;

import java.util.List;

@Mapper
public interface CommentMapper {
    // 插入
    @Insert("insert into comment(user_id,order_id,flower_id,level,message) values(#{userId},#{orderId},#{flowerId},#{level},#{message})")
    int insertComment(Comment comment);

    //根据flowerId查询评论
    @Select("select * from comment where flower_id=#{flowerId}")
    List<Comment> selectCommentByFlowerId(Integer flowerId);

    //根据user_id和order_id删除评论
    @Delete("delete from comment where user_id=#{userId} and order_id=#{orderId}")
    int deleteCommentByUserIdAndOrderId(Integer userId, String orderId);

    //根据user_id和order_id改评论
    @Update("update comment set level=#{level},message=#{message} where user_id=#{userId} and order_id=#{orderId}")
    int updateCommentByUserIdAndOrderId(Comment comment);

}